/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-29 12:43:28
 * @Description  : 分享管理相关接口
 */

import type {
  ShareCreateReq,
  SharePageRes,
  ShareUpdateReq,
  SetStatusShare,
  ShareReq,
  ShareCancelReq,
  UserShareReq,
  ShareRes
} from '@/types/share'
import request from '@/utils/request'

// 分页查询分享接口
export const getShareByPage = (params?: ShareReq) => {
  return request.get<SharePageRes>('/share/list', { params })
}

// 前台用户分页查询接口
export const getUserShareByPage = (params?: UserShareReq) => {
  return request.get<SharePageRes>('/share/user/list', { params })
}

// 获取分享给我的内部协作
export const getUserInnerShareByPage = (params?: UserShareReq) => {
  return request.get<SharePageRes>('/share/shareToMe/list', { params })
}

// 用户根据ID查询分享详情接口
export const getLinkShareById = (params: { shareId: string }) => {
  return request.get<ShareRes>('/share/id/list', { params })
}

// 添加分享接口
export const createShare = (data: ShareCreateReq) => {
  return request.post('/share/create', data)
}

// 更新分享接口
export const updateShare = (data: ShareUpdateReq) => {
  return request.put('/share/update', data)
}

// 取消分享接口
export const cancelShare = (data: ShareCancelReq) => {
  return request.put('/share/cancel', data)
}

// 开启/关闭分享接口
export const setStatusShare = (data: SetStatusShare) => {
  return request.put('/share/sort', data)
}

// 分享删除接口
export const delShare = (shareIds: string[]) => {
  return request.delete('/share/delete', { data: { shareIds } })
}

// 外链分享下载数增加
export const addShareNumDownload = (shareId: string) => {
  return request.put('/share/numDownload/add', { data: { shareId } })
}
// 外链分享浏览数增加
export const addShareNumView = (shareId: string) => {
  return request.put('/share/numView/add', { data: { shareId } })
}
